
package com.insigma.business.qrcode.common.converter;


import com.insigma.business.qrcode.soldier.dto.CommonAuthInfoDTO;
import com.insigma.business.qrcode.soldier.entity.CommonAuthInfoDO;
import com.insigma.business.qrcode.soldier.request.CommonAuthInfoBSearcher;
import com.insigma.business.qrcode.soldier.request.CommonAuthInfoInsertRequest;
import com.insigma.business.qrcode.soldier.request.CommonAuthInfoSearchRequest;
import com.insigma.business.qrcode.soldier.request.CommonAuthInfoUpdateRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CommonAuthInfoProviderConverter extends AbstractConverter<CommonAuthInfoDTO, CommonAuthInfoDO> {

    private final static CommonAuthInfoProviderConverter commonAuthInfoConverter = new CommonAuthInfoProviderConverter();

    private CommonAuthInfoProviderConverter(){}

    
    public static CommonAuthInfoBSearcher convertRequestSO2Searcher(final CommonAuthInfoSearchRequest request){
        final CommonAuthInfoBSearcher commonAuthInfoBSearcher = new CommonAuthInfoBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,commonAuthInfoBSearcher);
        return commonAuthInfoBSearcher;
    }

    
    public static CommonAuthInfoDO convertRequestUO2DO(final CommonAuthInfoUpdateRequest commonAuthInfoUpdateRequest) {
        final CommonAuthInfoDO commonAuthInfoDO = new CommonAuthInfoDO();
        BeanUtils.copyProperties(commonAuthInfoUpdateRequest,commonAuthInfoDO);
        
        return commonAuthInfoDO;
    }

    
    public static CommonAuthInfoDO convertRequestIO2DO(final CommonAuthInfoInsertRequest commonAuthInfoInsertRequest) {
        final CommonAuthInfoDO commonAuthInfoDO = new CommonAuthInfoDO();
        BeanUtils.copyProperties(commonAuthInfoInsertRequest,commonAuthInfoDO);
        return commonAuthInfoDO;
    }

    
    public static List<CommonAuthInfoDTO> convertResponseDOList2DTOList(final List<CommonAuthInfoDO> commonAuthInfoDOList){
        return commonAuthInfoConverter.convertGenericResponseDOList2DTOList(commonAuthInfoDOList);
    }

    
    public static CommonAuthInfoDTO convertResponseDO2DTO(final CommonAuthInfoDO commonAuthInfoDO){
        return commonAuthInfoConverter.convertGenericResponseDO2DTO(commonAuthInfoDO);
    }

    
    @Override
    protected CommonAuthInfoDTO doConvertResponseDO2DTO(CommonAuthInfoDO commonAuthInfoDO) {
        final CommonAuthInfoDTO commonAuthInfoDTO = new CommonAuthInfoDTO();
        try {
            BeanUtils.copyProperties(commonAuthInfoDO, commonAuthInfoDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return commonAuthInfoDTO;
    }

}
